package org.example.mallchat.common.intecepter;

import jdk.nashorn.internal.parser.Token;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: zzh
 * @date: 2024/12/22 22:06:31
 * @version: 1.0
 */
@Configuration
public class IntercepterSpring implements WebMvcConfigurer {

    @Autowired
    private TokenIntercepter tokenInterceptor;

    @Autowired
    private CollectIntercepter collectInterceptor;

    @Autowired
    private BlackIntercepter blackIntercepter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 为什么不能带前缀！
//        registry.addInterceptor(tokenInterceptor).addPathPatterns("/chatApi/**");
//        registry.addInterceptor(collectInterceptor).addPathPatterns("/chatApi/**");
//        registry.addInterceptor(blackIntercepter).addPathPatterns("/chatApi/**");
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**");
        registry.addInterceptor(collectInterceptor).addPathPatterns("/**");
        registry.addInterceptor(blackIntercepter).addPathPatterns("/**");
    }
}
